<cfparam name="f" default="docs">
<cfparam name="dir" default="/">
<cfparam name="page_content" default=" ">
<cfparam name="page_name" default="New Page">
<cfparam name="layout" default="layout1">
<cfset layoutfile = '#layout#.html'>
<cfset layoutfile = '#request.adminpath#components/pages/resource/layouts/#layoutfile#'>

<cffile action = "read" file="#layoutfile#" variable="page_content">

<cfif isdefined('form.savepage')>
	<!---page not found so write new page and redirect--->
	<cffile action="write" output="#page_content#" file="#request.basepath##f##dir##NewFileWithExt#">
	<div id="messages">New page was added</div>
	<p>
	<cfoutput>
	Your browser will redirect in a few seconds...<br />
	<a href = "index.cfm?c=pages&a=default&f=#f#&dir=#dir#">Click here if it does not redirect in 5 seconds</a>
	</p>
	<script language="javascript">
	pageurl = 'index.cfm?c=pages&a=default&f=#f#&dir=#dir#';
	setTimeout('delayer(pageurl)', 3000);
	</script>
	</cfoutput>
</cfif>
<cfinclude template = "#request.absolutepath#includes/loadstyles.cfm">
<cfinclude template = "#request.absoluteadminpath#includes/loadscripts.cfm">
<cfif fileexists('#request.basepath#themes/#request.site_theme#/layouts/#request.site_defaultlayout#/header.cfm')>
	<cfinclude template="#request.absolutepath#themes/#request.site_theme#/layouts/#request.site_defaultlayout#/header.cfm">
</cfif>
<cfoutput>
<form id="theForm" method="post" action="index.cfm?c=pages&a=new&f=#f#&dir=#dir#">
Name: 
<input name="page_name" type="hidden" value="#page_name#" size="60"><input type="submit" value="Add Page" Name="savepage" id="abutton" class="abutton"><br />
<textarea name="page_content" id="page_content" style="width: 100%; height: 450px;" class="tinymce">#page_content#</textarea>
</form>
</cfoutput>

<cfif fileexists('#request.basepath#themes/#request.site_theme#/layouts/#request.site_defaultlayout#/footer.cfm')>
	<cfinclude template="#request.absolutepath#themes/#request.site_theme#/layouts/#request.site_defaultlayout#/footer.cfm">
</cfif>
